package edu.unf.cen6940.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllCategorys", query = "select myCategory from Category myCategory"),
		//@NamedQuery(name = "findRandomCategorys", query = "select myCategory from Category myCategory ORDER BY NEWID()"),
		@NamedQuery(name = "findRandomCategorys", query = "select myCategory from Category myCategory"),
		@NamedQuery(name = "findCategoryByCategoryDescription", query = "select myCategory from Category myCategory where myCategory.categoryDescription = ?1"),
		@NamedQuery(name = "findCategoryByCategoryDescriptionContaining", query = "select myCategory from Category myCategory where myCategory.categoryDescription like ?1"),
		@NamedQuery(name = "findCategoryByCategoryId", query = "select myCategory from Category myCategory where myCategory.categoryId = ?1"),
		@NamedQuery(name = "findCategoryByPrimaryKey", query = "select myCategory from Category myCategory where myCategory.categoryId = ?1") })
@Table(catalog = "ThesisManagement", name = "Category")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "rms_test/edu/unf/cen6940/domain", name = "Category")
public class Category implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "categoryID", nullable = false)
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer categoryId;
	/**
	 */

	@Column(name = "categoryDescription", length = 45, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String categoryDescription;

	/**
	 */
	@ManyToMany(mappedBy = "categories", fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.unf.cen6940.domain.Thesis> thesises;
	/**
	 */
	@ManyToMany(mappedBy = "categories", fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.unf.cen6940.domain.Facultyresearch> facultyresearchs;

	/**
	 */
	public void setCategoryId(Integer categoryId) {
		this.categoryId = categoryId;
	}

	/**
	 */
	public Integer getCategoryId() {
		return this.categoryId;
	}

	/**
	 */
	public void setCategoryDescription(String categoryDescription) {
		this.categoryDescription = categoryDescription;
	}

	/**
	 */
	public String getCategoryDescription() {
		return this.categoryDescription;
	}

	/**
	 */
	public void setThesises(Set<Thesis> thesises) {
		this.thesises = thesises;
	}

	/**
	 */
	public Set<Thesis> getThesises() {
		if (thesises == null) {
			thesises = new java.util.LinkedHashSet<edu.unf.cen6940.domain.Thesis>();
		}
		return thesises;
	}

	/**
	 */
	public void setFacultyresearchs(Set<Facultyresearch> facultyresearchs) {
		this.facultyresearchs = facultyresearchs;
	}

	/**
	 */
	public Set<Facultyresearch> getFacultyresearchs() {
		if (facultyresearchs == null) {
			facultyresearchs = new java.util.LinkedHashSet<edu.unf.cen6940.domain.Facultyresearch>();
		}
		return facultyresearchs;
	}

	/**
	 */
	public Category() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Category that) {
		setCategoryId(that.getCategoryId());
		setCategoryDescription(that.getCategoryDescription());
		setThesises(new java.util.LinkedHashSet<edu.unf.cen6940.domain.Thesis>(that.getThesises()));
		setFacultyresearchs(new java.util.LinkedHashSet<edu.unf.cen6940.domain.Facultyresearch>(that.getFacultyresearchs()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("categoryId=[").append(categoryId).append("] ");
		buffer.append("categoryDescription=[").append(categoryDescription).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((categoryId == null) ? 0 : categoryId.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Category))
			return false;
		Category equalCheck = (Category) obj;
		if ((categoryId == null && equalCheck.categoryId != null) || (categoryId != null && equalCheck.categoryId == null))
			return false;
		if (categoryId != null && !categoryId.equals(equalCheck.categoryId))
			return false;
		return true;
	}
}
